home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SATAN11.ZIP / SRC / PORT_SCA / NON_BLOC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-04  |  519 b   |  30 lines

  1.  /*
  2.   * non_blocking - set/clear open file non-blocking I/O flag
  3.   * 
  4.   * Environment: POSIX, 43BSD
  5.   * 
  6.   * Author: Wietse Venema.
  7.   */
  8.  
  9. #include <sys/types.h>
  10. #include <fcntl.h>
  11.  
  12. /* Backwards compatibility */
  13. #ifdef FNDELAY
  14. #define PATTERN    FNDELAY
  15. #else
  16. #define PATTERN    O_NONBLOCK
  17. #endif
  18.  
  19. non_blocking(fd, on)
  20. int     fd;
  21. int     on;
  22. {
  23.     int     flags;
  24.  
  25.     if ((flags = fcntl(fd, F_GETFL, 0)) < 0)
  26.     return -1;
  27.     return fcntl(fd, F_SETFL, on ? flags | PATTERN : flags & ~PATTERN);
  28. }
  29.  
  30.